import requests
import jieba.posseg as pseg

def get_yyys(cookies,host,name,jigouma):
    try:
        cookies = {
            'JSESSIONID': f'{cookies}',
        }

        headers = {
            'Accept': 'application/json',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36',
        }

        params = {
            'limit': '22',
            '_dch': '1754238350536',
        }

        json_data = {
            'EQ_signTeamCode': '',
            'GTE_signDate': '',
            'LTE_signDate': '',
            'GTE_endDate': '',
            'LTE_endDate': '',
            'GTE_firstDate': '',
            'LTE_firstDate': '',
            'EQ_validityPeriod': '',
            'EQ_operator': '',
            'LIKE_personName': f'{name}%',
            'EQ_idNumber': '',
            'NE_contractState': '',
            'LTE_dateCreatedSys': '',
            'GTE_dateCreatedSys': '',
            'EQ_signOrgCode': f'{jigouma}',
            'LIKE_signOrgCode': ' ',
        }

        response = requests.post(
            f'{host}/phis/app/fds/contract/individual',
            params=params,
            cookies=cookies,
            headers=headers,
            json=json_data,
            verify=False,
        )

        yyys = ""
        # 识别文本中的人名实体
        words = pseg.cut(response.json()['content'][0]['signTeamName'])
        for word, flag in words:
            if flag == 'nr':  # nr 表示人名
                yyys = word
        return yyys
    except:
        return ""

if __name__ == '__main__':
    print(get_yyys('B350E396E86E0D5AFB7A08EF46841F8B', 'http://10.216.11.24:8306', '韩武', '0709'))
